-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use work.mem_hierarchy_pack.all;
-------------------------------------------------------------------------------
entity mem_hierarchy_tb is
end mem_hierarchy_tb;
-------------------------------------------------------------------------------
architecture test_bench of mem_hierarchy_tb is

  signal T_clk  : std_logic;
  signal T_rst  : std_logic;

  signal T_rw   : std_logic;
  signal T_cs   : std_logic;

  signal T_addr : std_logic_vector(31 downto 0);
  signal T_din  : std_logic_vector(31 downto 0);

  signal T_rdy  : std_logic;
  signal T_dout : std_logic_vector(31 downto 0);

begin -- test_bench
-------------------------------------------------------------------------------
  MH : mem_hierarchy
    port map (
      T_clk, T_rst,
      T_rw,   -- rw
      T_cs,   -- cs
      T_addr, -- addr
      T_din,  -- din
      T_rdy,  -- rdy
      T_dout  -- dout
    );
-------------------------------------------------------------------------------
  process
  begin
    T_clk <= '0';
    wait for 5 ns;
    T_clk <= '1';
    wait for 5 ns;
  end process;
-------------------------------------------------------------------------------
  test: process
  begin -- test
    T_rst <= '1', '0' after 1 ns;

    T_rw   <= '0';
    T_cs   <= '0';
    T_addr <= (others => '0');
    T_din  <= (others => '0');

    wait for 20 ns;

    T_rw   <= '1', '0' after 200 ns;
    T_cs   <= '1', '0' after 200 ns;
    T_addr <= "00000000000000000000000000001100";
    T_din  <= (others => '1');

    wait for 200 ns;

    T_rw   <= '0';
    T_cs   <= '1', '0' after 250 ns;
    T_addr <= "00000000000000000000001000000100";
    T_din  <= (others => '0');

    wait for 250 ns;

    T_rw   <= '0';
    T_cs   <= '1', '0' after 350 ns;
    T_addr <= "00000000000000000000010000000000"; -- edit tag
    T_din  <= (others => '0');

    wait for 350 ns;

  end process test;
-------------------------------------------------------------------------------
end test_bench;
